package com.ygqh.baby.controller.admin;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.ygqh.baby.ao.Message;
import com.ygqh.baby.po.AdminMarketingContract;
import com.ygqh.baby.po.AdminUser;
import com.ygqh.baby.service.AdminMarketingContractService;
import com.ygqh.baby.shiro.utils.SessionUtil;

@Controller
@RequestMapping("/admin/marketing")
public class MarketingContractController extends BaseController<Object, java.lang.Long> {
	@Autowired
	private AdminMarketingContractService adminMarketingContractService;

	@RequestMapping("/save")
	@ResponseBody
	public Message save(String contractStr) {
		AdminUser user = SessionUtil.getCurrentUser();
		AdminMarketingContract adminContract = JSON.parseObject(contractStr, AdminMarketingContract.class);
		adminContract.setCreateBy(user.getTrueName());
		adminContract.setCreateTime(new Date());
		adminContract.setUpdateBy(user.getTrueName());
		adminContract.setUpdateTime(adminContract.getCreateTime());
		int i = adminMarketingContractService.save(adminContract);
		return Message.success(i);

	}
	@RequestMapping("/findById")
	@ResponseBody
	public Message findById(Long id) {
		AdminMarketingContract contract = adminMarketingContractService.findById(id);
		return Message.success(contract);
		
	}

}
